import pandas as pd

data_frame = pd.DataFrame([[28, None, 3], [30, 16000, 7], [30, 30000, 4], [33, 23000, None]],
                          columns=['年龄', '收入', '家属数'])
print('读取前10行数据：head(10)', data_frame.head(10))
print('显示行列数：shape', data_frame.shape)
print('查看行信息：info', data_frame.info)
print('查看行信息：info()', data_frame.info())
print('获取所有数值类型字段的分布值：describe()', data_frame.describe())
print('查看每个字段是否为null：isnull()', data_frame.isnull())
print('删除有空值的行：dropna()', data_frame.dropna())
print('删除有全部为空值的行：dropna(how="all")', data_frame.dropna(how="all"))
print('填充为null的字段：fillna(0)（默认填充）', data_frame.fillna(0))
print('填充为null的字段：fillna(dict)（按照dict填充）', data_frame.fillna({"收入": 1000, '家属数': 8}))
print('删除重复行：drop_duplicates()', data_frame.drop_duplicates(subset=["年龄"], keep="first"))
print('查看某一列的数据类型：dtype', data_frame['年龄'].dtype)
print('数据类型转换：astype(int64)', data_frame['收入'].astype('int64', errors='ignore'))
